package com.guozcc.gateway.utils;


import com.guozcc.gateway.vo.Head;
import com.guozcc.gateway.vo.ResultVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ResultUtils {

    private final static Logger log = LoggerFactory.getLogger(com.guozcc.gateway.utils.ResultUtils.class);

    public static <T> ResultVO<T> success(T data){
        return new ResultVO(GatewayStatus.TRADE_SUCCESS.errcode(),GatewayStatus.TRADE_SUCCESS.errmsg(),data);
    }
    public static <T> ResultVO<T> success(int in){
        return new ResultVO(GatewayStatus.TRADE_SUCCESS.errcode(),GatewayStatus.TRADE_SUCCESS.errmsg(),in);
    }

    public static <T> ResultVO<T> success(String errmsg,T data){
        return new ResultVO(GatewayStatus.TRADE_SUCCESS.errcode(),errmsg,data);
    }

    public static <T> ResultVO<T> fail(String errcode,String errmsg,T data){
//        log.info("交易失败errcode="+errcode+",errmsg="+errmsg);
        return new ResultVO(errcode,errmsg,data);
    }

    public static <T> ResultVO<T> fail(String errcode,String errmsg){
//        log.info("交易失败errcode="+errcode+",errmsg="+errmsg);
        return new ResultVO(new Head(errcode,errmsg));
    }
}
